import execjs
import requests


def js_code(data):
    with open('全国招标数据解码.js', 'r', encoding='utf-8') as f:
        js_file = execjs.compile(f.read()).call('decryptByDES',data)
    return  js_file

def data(page):
    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36 Edg/118.0.2088.76",
        "Referer": "https://ctbpsp.com/",
    }
    url = f"https://ctbpsp.com/cutominfoapi/recommand/type/5/pagesize/10/currentpage/{page}"
    response = requests.get(url, headers=headers).content.decode()
    resp = response.replace('"','')
    return js_code(resp)

if __name__ == '__main__':
    for page in range(1,5):
        print(data(page))
